package app;

import geom.Line;
import geom.Vector;

import java.util.ArrayList;
import java.util.Iterator;

import path.*;
import processing.core.PApplet;


public class ProbaDraw extends PApplet{
	ArrayList<Line> paths;
	Line path;
	public void setup(){
		frameRate(30);
		size(800, 800);
		paths = new ArrayList<Line>();
	}
	
	
	public void mousePressed(){
		path = new Line(this);
		paths.add(path);
	}
	
	public void mouseDragged(){
		path.addPoint(new Vector(mouseX, mouseY, 0));
	}
	
	public void draw(){
		background(0);
		Iterator<Line> it = paths.iterator();
		while(it.hasNext()){
			it.next().draw();
		}
	}
	
	public class DrawPath implements PathDrawer{

		public void drawPath(Path path, PApplet pa) {
			pa.stroke(200, 75, 100);
			Iterator<KeyFrame> kf = path.getKeyFrames().iterator();
			Vector prev = null;
			while(kf.hasNext()){
				Vector pos = kf.next().getPosition();
				pa.ellipse(pos.x, pos.y, 2, 2);
				if(prev != null){
					pa.line(prev.x, prev.y, pos.x, pos.y);
				}
				prev = pos;
			}
			
		}

		public void keyAdded(Path p) {
			// TODO Auto-generated method stub
			
		}

		public void keyRemoved(Path p, int i) {
			// TODO Auto-generated method stub
			
		}

		public void keysAdded(Path p, int size) {
			// TODO Auto-generated method stub
			
		}
		
	}

}
